home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGASIC / BASFILES.LZH / BASTOBIN.BAS < prev    next >
BASIC Source File  |  1988-09-10  |  756b  |  27 lines

  1. '$INCLUDE:'QBTOOLS.INC'
  2. '' DECLARE FUNCTION BaseToBin$ (Numbase%, Number$)
  3. '' '$INCLUDE: 'qbtools.inc'
  4.  
  5. FUNCTION BaseToBin$ (Numbase%, Number$) STATIC
  6.  
  7.     Base10% = BaseToReal(Numbase%, Number$)              'Convert to base 10
  8.     out$ = ""                                            'Clear output string
  9.  
  10.     IF Base10% = -1 THEN                                 'Return error if error
  11.         BaseToBin$ = "-1"                                 ' in calculating base 10
  12.         EXIT FUNCTION
  13.     END IF
  14.  
  15.     FOR i% = 7 TO 0 STEP -1                              'Conversion
  16.         IF Base10% AND 2 ^ i% THEN
  17.             out$ = out$ + "1"
  18.         ELSE
  19.             out$ = out$ + "0"
  20.         END IF
  21.     NEXT i%
  22.     
  23.     BaseToBin$ = out$                               'Return to Function
  24.     
  25. END FUNCTION
  26.  
  27.